
//登录的方法
function login(){
    var account=$("#account").val();
    var password=$("#password").val();
    $.ajax({
        url:contextPath+"/login",
        method:"post",
        data:{account:account,password:password,action:"login"},
        success:function(jsonStr){
            var result=eval("("+jsonStr+")");
            if(result.status==1){
                window.location.href=contextPath+"/home?action=index";
            }else{
                showMessage(result.message)
            }
        }
    })
}

//发送验证码
function sendVerifyCode(){
    var phone = $("#phone").val();
    if (null == phone || phone.length != 11) {
        showMessage("请输入11位手机号码！")
    }
    $.ajax({
        url:contextPath+"/login",
        method:"post",
        data:{phone:phone,action:"sendVerifyCode"},
        success:function(jsonStr){
            var result=eval("("+jsonStr+")");
            showMessage(result.message);
        }
    })
}

//验证码登录的方法
function loginByCode(){
    var phone = $("#phone").val();
    var code = $("#code").val();
    if (null == code || code.length != 4) {
        showMessage("请输入4位验证码！")
    }

    $.ajax({
        url:contextPath+"/login",
        method:"post",
        data:{phone:phone,code:code,action:"loginByCode"},
        success:function(jsonStr){
            var result=eval("("+jsonStr+")");
            if(result.status==1){
                window.location.href=contextPath+"/home?action=index";
            }else{
                showMessage(result.message)
            }
        }
    })
}
